package co.com.javeriana.aes.oms.common.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Jonathan Fernandez <jonathan.fvargas@gmail.com>
 */
@Entity
@Table(name = "ITEMS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Items.findAll", query = "SELECT i FROM Items i"),
    @NamedQuery(name = "Items.findByItemid", query = "SELECT i FROM Items i WHERE i.itemid = :itemid"),
    @NamedQuery(name = "Items.findByProdid", query = "SELECT i FROM Items i WHERE i.prodid = :prodid"),
    @NamedQuery(name = "Items.findByProductname", query = "SELECT i FROM Items i WHERE i.productname = :productname"),
    @NamedQuery(name = "Items.findByPartnum", query = "SELECT i FROM Items i WHERE i.partnum = :partnum"),
    @NamedQuery(name = "Items.findByPrice", query = "SELECT i FROM Items i WHERE i.price = :price"),
    @NamedQuery(name = "Items.findByQuantity", query = "SELECT i FROM Items i WHERE i.quantity = :quantity")})
public class Items implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ITEMID")
    @SequenceGenerator(name="ITEMSSQ", initialValue=1, allocationSize=100)
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ITEMSSQ")  
    private Integer itemid;
    @Basic(optional = false)
    @Column(name = "PRODID")
    private int prodid;
    @Basic(optional = false)
    @Column(name = "PRODUCTNAME")
    private String productname;
    @Column(name = "PARTNUM")
    private String partnum;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation   
    @Column(name = "PRICE")
    private BigDecimal price;
    @Basic(optional = false)
    @Column(name = "QUANTITY")
    private int quantity;    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ORDERS_ORDID", referencedColumnName = "ORDID")    
    private Orders ordersOrdid;

    public Items() {
    }

    public Items(Integer itemid) {
        this.itemid = itemid;
    }

    public Items(Integer itemid, int prodid, String productname, int quantity) {
        this.itemid = itemid;
        this.prodid = prodid;
        this.productname = productname;
        this.quantity = quantity;
    }

    public Integer getItemid() {
        return itemid;
    }

    public void setItemid(Integer itemid) {
        this.itemid = itemid;
    }

    public int getProdid() {
        return prodid;
    }

    public void setProdid(int prodid) {
        this.prodid = prodid;
    }

    public String getProductname() {
        return productname;
    }

    public void setProductname(String productname) {
        this.productname = productname;
    }

    public String getPartnum() {
        return partnum;
    }

    public void setPartnum(String partnum) {
        this.partnum = partnum;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public Orders getOrdersOrdid() {
        return ordersOrdid;
    }

    public void setOrdersOrdid(Orders ordersOrdid) {
        this.ordersOrdid = ordersOrdid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemid != null ? itemid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Items)) {
            return false;
        }
        Items other = (Items) object;
        if ((this.itemid == null && other.itemid != null) || (this.itemid != null && !this.itemid.equals(other.itemid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.com.javeriana.aes.oms.common.entity.Items[ itemid=" + itemid + " ]";
    }
    
}
